<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>04-获取焦点和失去焦点事件</title>
    <script>
        window.onload=function () {
            document.getElementById("username").onfocus=function () {
                console.log("获取焦点");
            }
            document.getElementById("username").onblur=function () {
                console.log("失去焦点");
            }
        }
    </script>
</head>
<body>
<input type="text" id="username">
</body>
</html>